//
//  LineScatterCandleRadarRenderer.swift
//  Charts
//
//  Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda
//  A port of MPAndroidChart for iOS
//  Licensed under Apache License 2.0
//
//  https://github.com/danielgindi/Charts
//

import Foundation
import CoreGraphics

@objc(LineScatterCandleRadarChartRenderer)
open class LineScatterCandleRadarRenderer: BarLineScatterCandleBubbleRenderer
{
//    open func chart_hexColor(_ hex: String, alpha: CGFloat = 1.0) -> UIColor{
//     guard hex.count >= 6 else {
//         return UIColor.white
//     }
//     let hexString = hex.trimmingCharacters(in: .whitespacesAndNewlines)
//     let scanner = Scanner(string: hexString)
//      
//     if hexString.hasPrefix("#") {
//         scanner.scanLocation = 1
//     }
//      
//     var color: UInt32 = 0
//     scanner.scanHexInt32(&color)
//      
//     let mask = 0x000000FF
//     let r = Int(color >> 16) & mask
//     let g = Int(color >> 8) & mask
//     let b = Int(color) & mask
//      
//     let red   = CGFloat(r) / 255.0
//     let green = CGFloat(g) / 255.0
//     let blue  = CGFloat(b) / 255.0
//     
//     return UIColor(red: red, green: green, blue: blue, alpha: alpha)
// }
//    
    public override init(animator: Animator, viewPortHandler: ViewPortHandler)
    {
        super.init(animator: animator, viewPortHandler: viewPortHandler)
    }
    
    /// Draws vertical & horizontal highlight-lines if enabled.
    /// :param: context
    /// :param: points
    /// :param: horizontal
    /// :param: vertical
    @objc open func drawHighlightLines(context: CGContext, point: CGPoint, set: LineScatterCandleRadarChartDataSetProtocol)
    {
        
        // draw horizontal highlight lines
        if set.isHorizontalHighlightIndicatorEnabled
        {
            
            context.setLineDash(phase: set.highlightLineDashPhase, lengths: set.highlightLineDashLengths!)
            context.beginPath()
            context.move(to: CGPoint(x: viewPortHandler.contentLeft, y: point.y))
            context.addLine(to: CGPoint(x: viewPortHandler.contentRight, y: point.y))
            context.strokePath()
        }
        
        // draw vertical highlight lines
        if set.isVerticalHighlightIndicatorEnabled
        {
           
            if !set.needVerDashLine {
                context.setLineDash(phase: set.highlightLineDashPhase, lengths: set.highlightLineDashLengths!)
            } else {
                context.setLineDash(phase: 0.0, lengths: [])
            }
            
            context.beginPath()
            context.move(to: point);
            context.addLine(to: CGPoint(x: point.x, y: viewPortHandler.contentBottom))
            context.strokePath()

        }
        
        //画圆
        context.beginPath()
        context.setFillColor(set.radiusOutLineColor.cgColor)
        context.addArc(center: point, radius: 10, startAngle: Double.pi, endAngle: -Double.pi, clockwise: true)
        context.drawPath(using: .fill)
        context.closePath()
        
    
        context.beginPath()
        context.setFillColor(set.radiusLineColor.cgColor)
        context.addArc(center: point, radius: 8, startAngle: Double.pi, endAngle: -Double.pi, clockwise: true)
        context.drawPath(using: .fill)
        context.closePath()
        

        context.beginPath()
        context.setFillColor(set.radiusOutLineColor.cgColor)
        context.addArc(center: point, radius: 5, startAngle: Double.pi, endAngle: -Double.pi, clockwise: true)
        context.drawPath(using: .fill)
        context.closePath()

        
    }
  
    

}

 
